<?php
 
// your ftp credentials
$ftp_server='launchyourproduct.com';
$ftp_user='ftplyp';
$ftp_pass='karmoITn84';
 
// where is Joomla installed? (trailing slash required)
$base = '/httpdocs/hoc/';
 
// what files or directories need chmod applied? (trailing slash optional)
$dirs = array( 'administrator/backups',
               'administrator/components',
               'administrator/language',
               'administrator/language/en-GB',
               'administrator/modules',
               'administrator/templates',
               'administrator/cache',
               'components',
               'images',
               'images/banners',
               'images/stories',
               'media',
               'language',
               'language/en-GB',
               'language/pdf_fonts',
               'modules',
               'plugins',
               'plugins/content',
               'plugins/editors',
               'plugins/editors-xtd',
               'plugins/search',
               'plugins/system',
               'plugins/user',
               'plugins/xmlrpc',
               'tmp',
               'templates',
               'cache'
             );
 
// default to safe 0755 setting
if (isset($_GET['chmod'])) {
    $ftp_chmod = $_GET['chmod']; 
} else {
    $ftp_chmod = "0777"; 
}
echo "chmod=".$ftp_chmod.'<br/>';
 
// connect via ftp and apply chmod
$conn_id = ftp_connect("$ftp_server");
ftp_login($conn_id, $ftp_user, $ftp_pass);
foreach( $dirs as $dir ){
    if (ftp_site($conn_id, 'CHMOD '.$ftp_chmod.' '.$base.$dir)) { 
        echo "success "; 
    } else { 
        echo "failed "; 
    }
    echo $base.$dir.'<br/>';
} 
ftp_close($conn_id);
 
echo 'DONE';
?>
